package org.SoccerTournament.model;

import java.util.HashSet;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.OneToOne;
import javax.persistence.Table;


@Entity
@Table(name = "Stadiums")
public class Stadium {
	
	private Long stadiumId;
	
	private String name;

	private  Set<Team> teams = new HashSet<Team>();
	
	private Zone zone;



	@Id
	@GeneratedValue
	@Column(name="stadiumId")
	public Long getStadiumId() {
		return stadiumId;
	}
	
	@ManyToMany(cascade=CascadeType.ALL,fetch = javax.persistence.FetchType.LAZY,targetEntity=Team.class)
	@JoinTable(name = "team_stadium", 
			   joinColumns = {@JoinColumn(name = "stadiumId")},
			   inverseJoinColumns = {@JoinColumn(name = "teamId")}
			  )
	public Set<Team> getTeams() {
		return teams;
	}
	
	@OneToOne(fetch = FetchType.LAZY, cascade = CascadeType.ALL)
	@JoinColumn(name = "zoneId")
	public Zone getZone() {
		return zone;
	}

	public void setStadiumId(Long stadiumId) {
		this.stadiumId = stadiumId;
	} 
	
	public void setTeams(Set<Team> teams) {
		this.teams = teams;
	}
	
	public String getName() {
		return name;
	}
	
	public void setName(String name) {
		this.name = name;
	}
	
	
	public void setZone(Zone zone) {
		this.zone = zone;
	}
}
